package com.coolbi.common.util;

import java.util.Date;

import org.yaml.snakeyaml.Yaml;

public class YamlUtil {
	
	private static final Yaml yaml=new Yaml();
	/**
	 * 
	 */
	public static void serializationOutputToConsole(Object data){
		String name=data.getClass().getName();
		System.out.println("-------------------"+name+"------------------------");
		try{
			System.out.println(yaml.dump(data));
		}catch(Exception e){
			System.out.println("无法序列化！");
		}
		System.out.println("-------------------"+name+"------------------------");
	}
	
	public static String yamlSerialization(Object data){
		try{
			return yaml.dump(data);
		}catch(Exception e){
			return new Date()+"Error:"+e.getMessage()+"-";
		}
	}
}
